<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Insert comment</title>
</head>

<body>

<cfoutput>~trimstartshere2~</cfoutput>
<cfset mylist = #form.args#>
    
    	<cfset thefilterArr = ArrayNew(1)>
    
		<cfset thefilterArr = ListToArray(mylist , "~", "yes")>  
        
        <cfset thecollabcode  = Trim(thefilterArr[1])>
        <cfset theavatarpath  = Trim(thefilterArr[2])>
        <cfset theuserid      = Trim(thefilterArr[3])>
        <cfset thecontent     = Trim(thefilterArr[4])>
        <cfset fullname       = Trim(thefilterArr[5])>
        
<cfset guuiidd = CreateUUID() />
<cfset todaydate = DateFormat(Now(), "YYYY-MM-DD") />
<cfset todaytime = TimeFormat(Now(), "HH:MM:SS") />
<cfset todaydate = "#todaydate# #todaytime#" />


<cfquery name="updateRTcount" datasource="#client.company_dsn#">

	UPDATE ECRTCOLLAB
       SET COUNT = COUNT + 1
     WHERE ISALLOWED = 'Y' AND COLLABCODE = '#thecollabcode#' AND COUNT IS NOT NULL;

</cfquery>

<cfquery name="updateRTcount2" datasource="#client.company_dsn#">

	UPDATE ECRTCOLLAB
       SET DATECREATED = '#todaydate#'
     WHERE ISALLOWED = 'Y' AND COLLABCODE = '#thecollabcode#' AND COUNT IS NOT NULL;

</cfquery>

<cfquery name="insertComment" datasource="#client.company_dsn#">

	INSERT INTO ECINCOLLABDISC ( COMMENTID, COLLABCODE, USERID, MESSAGE, DATECREATED ) 
         VALUES ( '#guuiidd#',  '#thecollabcode#', '#theuserid#', '#thecontent#', '#todaydate#' );

</cfquery>



<cfoutput><tr>
			  <td>
              	  <div style='background-color: ##FFF; width: 50px; height: 50px; font-family: Arial, Helvetica, sans-serif;'><img src='<cfoutput>#theavatarpath#</cfoutput>' width='100%' height='100%'/></div>
              </td>
              <td border="0" bordercolor="##FFF" style="border-top: solid 1px ##CCC;">
                  <table border='0' bordercolor='##FFFFFF'>
                     <tr>
                         <td><span style='font-size: 1 em; font-weight: bold; font-family: Arial, Helvetica, sans-serif;'><cfoutput>#fullname#</cfoutput></span><span style='font-size: 1 em; font-family: Arial, Helvetica, sans-serif;'>&nbsp;&nbsp;A few seconds ago</span></td>
                     </tr>
                  </table>
              </td>
           </tr>
           <tr>
               <td>&nbsp;</td>
               <td>
                   <table border='0' bordercolor='##FFFFFF'>
                       <tr>
                           <td style="font-size: 1 em; font-family: Arial, Helvetica, sans-serif;">
                           <cfoutput>#thecontent#</cfoutput>
                           </td>
                       </tr>
                   </table>
               </td>
           </tr>
           
           
</cfoutput>
    
<cfoutput>~trimendshere2~</cfoutput>
    
	<cfquery name="getOwner" datasource="#client.company_dsn#" maxrows="1">

        SELECT B.USERID AS USERID
          FROM ECRGCOLLABTHREAD A JOIN ECRGCOLLAB B
            ON A.FOLDERCODE = B.FOLDERCODE
         WHERE A.COLLABCODE = '#thecollabcode#';
    
    </cfquery>

	<cfset profilename    = "_" />
    <cfset GGMAILPASSWORD = "_" />
    <cfset IIREDMAIL      = "_" />
    <cfset GGMAIL         = "_" />
    
    <cfquery name="getprofilename" datasource="#client.global_dsn#" maxrows="1">
            SELECT USERID, GMAIL, GMAILPASSWORD, IREDMAIL FROM EGRGUSERMASTER
            WHERE USERID = '#getOwner.USERID#';
    </cfquery>
    
    
        
           <cfoutput query="getprofilename">
                <cfset theKey="lqHDPhzTF8VMyrG0R/xx3A=="> 
            
                <cfset GGMAIL         = "#decrypt(GMAIL,theKey, "AES", "Base64")#">
                <cfset GGMAILPASSWORD = "#decrypt(GMAILPASSWORD,theKey, "AES", "Base64")#">
                <cfset IIREDMAIL      = "#decrypt(IREDMAIL,theKey, "AES", "Base64")#">
                
           </cfoutput>     
          
               
    
               
    
        <cfset profilename    = Trim(GGMAIL) />
        <cfset GGMAILPASSWORD = GGMAILPASSWORD />
        <cfset IIREDMAIL      = Trim(IIREDMAIL) /> 
    
    
    <cfmail
        server   = "smtp.gmail.com"
        port     = "587"
        type     = "html"
        useTLS   = "yes"
        username = "#profilename#"
        password = "#GGMAILPASSWORD#"
        from     = "#profilename#"
        to       = "#IIREDMAIL#,#profilename#"
        subject  = "#fullname# messaged you in iBOS/e eForum."
        >
         
        <cfoutput><p><img width="50px" height="50px" src="#theavatarpath#"></p><p> #fullname# says: </p><p>#thecontent#</p></cfoutput>
		<!---<p><a href="https://accounts.google.com/o/oauth2/auth?response_type=token&client_id=561695249357.apps.googleusercontent.com&redirect_uri=http://www.imachinecloud.com/etasks/applications/gmail/savetoken.cfm&scope=https://www.googleapis.com/auth/userinfo.email" target="_new">View eForums</a></p>
		--->
        <p><a href="<cfoutput>#client.domain#</cfoutput>ecollab/message/index.cfm?id=eforumstimeline">View in iBOS/e eForums</a></p>
    </cfmail>    
    
</body>
</html>
